<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title></title>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="root">
    <component :is="componentId"></component>
  </div>
  <script type="module">
    const comp1 = {
      template: `
        <div>component 1</div>
      `,
      mounted() {
        console.log(100)
      },
    }
    const comp2 = {
      template: `
        <div>component 2</div>
      `
    }
    const comp3 = {
      template: `
        <div>component 3</div>
      `
    }


    Vue.config.productionTip = false

    var vm = new Vue({
      el: '#root',
      data: {
        title: 'hello',
        componentId: 'comp1'
      },
      components: {
        comp1,
        comp2,
        comp3
      },
      mounted() {
        setTimeout(() => {
          this.componentId = 'comp2'
        }, 2000)
        setTimeout(() => {
          this.componentId = 'comp1'
        }, 4000)
      },
    })
  </script>
</body>
</html>